package com.ruoyi.teacher.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teacher.domain.TFile;
import com.ruoyi.teacher.service.ITFileService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人事档案管理信息Controller
 * 
 * @author xangzy
 * @date 2022-05-08
 */
@RestController
@RequestMapping("/teacher/personFile")
public class TFileController extends BaseController
{
    @Autowired
    private ITFileService tFileService;

    /**
     * 查询人事档案管理信息列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:personFile:list')")
    @GetMapping("/list")
    public TableDataInfo list(TFile tFile)
    {
        startPage();
        List<TFile> list = tFileService.selectTFileList(tFile);
        return getDataTable(list);
    }

    /**
     * 导出人事档案管理信息列表
     */
    @PreAuthorize("@ss.hasPermi('teacher:personFile:export')")
    @Log(title = "人事档案管理信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TFile tFile)
    {
        List<TFile> list = tFileService.selectTFileList(tFile);
        ExcelUtil<TFile> util = new ExcelUtil<TFile>(TFile.class);
        return util.exportExcel(list, "personFile");
    }

    /**
     * 获取人事档案管理信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:personFile:query')")
    @GetMapping(value = "/{recordid}")
    public AjaxResult getInfo(@PathVariable("recordid") Long recordid)
    {
        return AjaxResult.success(tFileService.selectTFileById(recordid));
    }

    /**
     * 新增人事档案管理信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:personFile:add')")
    @Log(title = "人事档案管理信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TFile tFile)
    {
        return toAjax(tFileService.insertTFile(tFile));
    }

    /**
     * 修改人事档案管理信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:personFile:edit')")
    @Log(title = "人事档案管理信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TFile tFile)
    {
        return toAjax(tFileService.updateTFile(tFile));
    }

    /**
     * 删除人事档案管理信息
     */
    @PreAuthorize("@ss.hasPermi('teacher:personFile:remove')")
    @Log(title = "人事档案管理信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordids}")
    public AjaxResult remove(@PathVariable Long[] recordids)
    {
        return toAjax(tFileService.deleteTFileByIds(recordids));
    }
}
